﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.Web.UI;
using System.Web.UI.WebControls;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
using System.Data;

/// <summary>
/// Summary description for PopulaDropDownList
/// </summary>
public class PopulaDropDownList
{
    ConexaoROBOT Command = new ConexaoROBOT();
    
    public PopulaDropDownList()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    public DataSet dsResultado(String cmd, DropDownList ddl, String DataValueField, String DataTextField, String NOME_FILT)
    {
        OracleCommand cmdOP = Command.cmdROBOT(cmd);

        cmdOP.Parameters.Add(new OracleParameter("V_COD_FILT", OracleDbType.Varchar2, ParameterDirection.Input)).Value = NOME_FILT;
        cmdOP.Parameters.Add(new OracleParameter("V_RESULTADO_SAIDA", OracleDbType.RefCursor, ParameterDirection.Output));

        OracleDataAdapter daResultado = new OracleDataAdapter();
        daResultado.SelectCommand = cmdOP;

        DataSet dsResultado = new DataSet();

        daResultado.Fill(dsResultado, "Resultado");

        ddl.DataSource = dsResultado.Tables["Resultado"];
        ddl.DataValueField = DataValueField;
        ddl.DataTextField = DataTextField;
        ddl.DataBind();

        cmdOP.Connection.Dispose();
        cmdOP.Connection.Close();

        return dsResultado;
    }
}
